const {daouser,daotittlechildsort,tittlefathersort,daotittle,modeltoken,comment}= require('../../dao/daoenter.js');
const JwtUtil = require('../../util/token/jwt.js');


const caddcomment =async (req,res)=>{

	
	let data={}

	data.uid=req.body.uid
	data.tittleid=req.body.tittleid
	data.content=req.body.content
	data.publishdate=new Date().getTime()
	

	if(data.tittleid!==''&&data.tittleid!==null&&data.uid!==''&&data.uid!==null){
		let hahares=await comment.addcomment(data)
		if(hahares){
		res.send({statue:'1',desc:"评论成功"})
		} else {
		res.send({statue:'0',desc:'评论失败'})
		}

	}else{
		res.send({status:'0',desc:'保存失败',reason:'id不符合'})
	}


}




const ccomment =async (req,res)=>{
    let hahares=await comment.commentfind()
	res.send(hahares)
}


const ccommentbyid =async (req,res)=>{
let data={}

 data.tittleid=req.query.tid

   let hahares=await comment.commentfindbyid(data)
console.log(hahares)
	res.send(hahares)
}





module.exports={
caddcomment,ccomment,ccommentbyid
	
}
